﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Templates_Profile_ForgottenPassword : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        btnSubmit.Click += new EventHandler(btnSubmit_Click);
        if (!IsPostBack)
        {
            if (Request.IsAuthenticated)
            {
                AcmsContext.RedirectToUrl("~/profile.aspx", this);
            }
            DataBind();
        }



    }

    void btnSubmit_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            var user = Acms.Bll.User.GetByEmailAddress(txtEmail.Text, AcmsContext.SiteId);
            if (user != null)
            {
                user.SendForgottenEmail(Server.MapPath("~/Sites/Man/Emails/ForgottenPassword.xml"));
                phSent.Visible = true;
                phForm.Visible = false;
            }
            else
            {
                phNotFound.Visible = true;
            }
        }
    }
}
